cc.Class({
    extends: cc.Component,

    properties: {
        button_sound:{  //爆炸音效
            type:cc.AudioClip,
            default:null
        },
       
    },


    onLoad () {
        this.init();
    },
    init:function(){
        this.hp=4;
        this.isDie=false;
        var anim=this.getComponent(cc.Animation);
        anim.play('enemynomal3');
    },
    hit:function(bulletHarm){
        this.hp-=bulletHarm;
       if(this.hp<=0){
        this.isDie=true;
        this.isOver();
        return;
       }
    },
    isOver:function(){
        var anim=this.getComponent(cc.Animation);
        anim.play('enemyDisappeared3');
        anim.disappeared=function(){
            this.onclickSound();
            game.addScore(30);
            game.onBullet_Killenemy(this.node,3);
        }.bind(this);
    },
    onclickSound:function(event,data){   //点击音效
        cc.audioEngine.play(this.button_sound,false,1);
    },

    update (dt) {
        if(game.isStart){
            this.node.y-=5;
        }
        if(this.node.y < -game.viewHeight/2){
            game.onBullet_Killenemy(this.node,3);
        }
    },
});
